package com.touni.designpattern.chainofresponsibilitypattern;

/**
 * @ClassName : ChainOfResponsibilityDemo
 * @Description : 责任链设计模式
 * @Author : lwq
 * @Date: 2020-11-12 17:02
 */
public class ChainOfResponsibilityDemo {
    public static AbstractLogger getLogger(){
        DebugLogger debugLogger = new DebugLogger(AbstractLogger.LOGGER_DEBUG);
        InfoLogger infoLogger = new InfoLogger(AbstractLogger.LOGGER_INFO);
        ErrorLogger errorLogger = new ErrorLogger(AbstractLogger.LOGGER_ERROR);
        debugLogger.setNextChain(infoLogger);
        infoLogger.setNextChain(errorLogger);
        return debugLogger;
    }

    public static void main(String[] args) {
        AbstractLogger logger = getLogger();
        logger.findChain(AbstractLogger.LOGGER_INFO,"  12");
        logger.findChain(AbstractLogger.LOGGER_ERROR, " 13");
        logger.findChain(AbstractLogger.LOGGER_DEBUG,"  15");
    }
}
